From c735556726e75428550a3d28a2cf58e2c8490b7d Mon Sep 17 00:00:00 2001 From: Dawid Rycerz Date: Mon, 21 Jul 2025 21:56:55 +0300 Subject: Initial template --- src/pages/[...blog]/[...page].astro | 52 +++++++++++++++++++++++++ src/pages/[...blog]/[category]/[...page].astro | 37 ++++++++++++++++++ src/pages/[...blog]/[tag]/[...page].astro | 37 ++++++++++++++++++ src/pages/[...blog]/index.astro | 54 ++++++++++++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100644 src/pages/[...blog]/[...page].astro create mode 100644 src/pages/[...blog]/[category]/[...page].astro create mode 100644 src/pages/[...blog]/[tag]/[...page].astro create mode 100644 src/pages/[...blog]/index.astro (limited to 'src/pages/[...blog]') diff --git a/src/pages/[...blog]/[...page].astro b/src/pages/[...blog]/[...page].astro new file mode 100644 index 0000000..5a6da41 --- /dev/null +++ b/src/pages/[...blog]/[...page].astro @@ -0,0 +1,52 @@ +--- +import type { InferGetStaticPropsType, GetStaticPaths } from 'astro'; + +import Layout from '~/layouts/PageLayout.astro'; +import BlogList from '~/components/blog/List.astro'; +import Headline from '~/components/blog/Headline.astro'; +import Pagination from '~/components/blog/Pagination.astro'; +// import PostTags from "~/components/blog/Tags.astro"; + +import { blogListRobots, getStaticPathsBlogList } from '~/utils/blog'; + +export const prerender = true; + +export const getStaticPaths = (async ({ paginate }) => { + return await getStaticPathsBlogList({ paginate }); +}) satisfies GetStaticPaths; + +type Props = InferGetStaticPropsType; + +const { page } = Astro.props as Props; +const currentPage = page.currentPage ?? 1; + +// const allCategories = await findCategories(); +// const allTags = await findTags(); + +const metadata = { + title: `Blog${currentPage > 1 ? ` — Page ${currentPage}` : ''}`, + robots: { + index: blogListRobots?.index && currentPage === 1, + follow: blogListRobots?.follow, + }, + openGraph: { + type: 'blog', + }, +}; +--- + + +
+ + The Blog + + + + +
+
diff --git a/src/pages/[...blog]/[category]/[...page].astro b/src/pages/[...blog]/[category]/[...page].astro new file mode 100644 index 0000000..e1c4ff6 --- /dev/null +++ b/src/pages/[...blog]/[category]/[...page].astro @@ -0,0 +1,37 @@ +--- +import type { InferGetStaticPropsType, GetStaticPaths } from 'astro'; +import { blogCategoryRobots, getStaticPathsBlogCategory } from '~/utils/blog'; + +import Layout from '~/layouts/PageLayout.astro'; +import BlogList from '~/components/blog/List.astro'; +import Headline from '~/components/blog/Headline.astro'; +import Pagination from '~/components/blog/Pagination.astro'; + +export const prerender = true; + +export const getStaticPaths = (async ({ paginate }) => { + return await getStaticPathsBlogCategory({ paginate }); +}) satisfies GetStaticPaths; + +type Props = InferGetStaticPropsType & { category: Record }; + +const { page, category } = Astro.props as Props; + +const currentPage = page.currentPage ?? 1; + +const metadata = { + title: `Category '${category.title}' ${currentPage > 1 ? ` — Page ${currentPage}` : ''}`, + robots: { + index: blogCategoryRobots?.index, + follow: blogCategoryRobots?.follow, + }, +}; +--- + + +
+ {category.title} + + +
+
diff --git a/src/pages/[...blog]/[tag]/[...page].astro b/src/pages/[...blog]/[tag]/[...page].astro new file mode 100644 index 0000000..86a767b --- /dev/null +++ b/src/pages/[...blog]/[tag]/[...page].astro @@ -0,0 +1,37 @@ +--- +import type { InferGetStaticPropsType, GetStaticPaths } from 'astro'; +import { blogTagRobots, getStaticPathsBlogTag } from '~/utils/blog'; + +import Layout from '~/layouts/PageLayout.astro'; +import BlogList from '~/components/blog/List.astro'; +import Headline from '~/components/blog/Headline.astro'; +import Pagination from '~/components/blog/Pagination.astro'; + +export const prerender = true; + +export const getStaticPaths = (async ({ paginate }) => { + return await getStaticPathsBlogTag({ paginate }); +}) satisfies GetStaticPaths; + +type Props = InferGetStaticPropsType; + +const { page, tag } = Astro.props as Props; + +const currentPage = page.currentPage ?? 1; + +const metadata = { + title: `Posts by tag '${tag.title}'${currentPage > 1 ? ` — Page ${currentPage} ` : ''}`, + robots: { + index: blogTagRobots?.index, + follow: blogTagRobots?.follow, + }, +}; +--- + + +
+ Tag: {tag.title} + + +
+
diff --git a/src/pages/[...blog]/index.astro b/src/pages/[...blog]/index.astro new file mode 100644 index 0000000..421927c --- /dev/null +++ b/src/pages/[...blog]/index.astro @@ -0,0 +1,54 @@ +--- +import type { InferGetStaticPropsType, GetStaticPaths } from 'astro'; + +import merge from 'lodash.merge'; +import type { ImageMetadata } from 'astro'; +import Layout from '~/layouts/PageLayout.astro'; +import SinglePost from '~/components/blog/SinglePost.astro'; +import ToBlogLink from '~/components/blog/ToBlogLink.astro'; + +import { getCanonical, getPermalink } from '~/utils/permalinks'; +import { getStaticPathsBlogPost, blogPostRobots } from '~/utils/blog'; +import { findImage } from '~/utils/images'; +import type { MetaData } from '~/types'; +import RelatedPosts from '~/components/blog/RelatedPosts.astro'; + +export const prerender = true; + +export const getStaticPaths = (async () => { + return await getStaticPathsBlogPost(); +}) satisfies GetStaticPaths; + +type Props = InferGetStaticPropsType; + +const { post } = Astro.props as Props; + +const url = getCanonical(getPermalink(post.permalink, 'post')); +const image = (await findImage(post.image)) as ImageMetadata | string | undefined; + +const metadata = merge( + { + title: post.title, + description: post.excerpt, + robots: { + index: blogPostRobots?.index, + follow: blogPostRobots?.follow, + }, + openGraph: { + type: 'article', + ...(image + ? { images: [{ url: image, width: (image as ImageMetadata)?.width, height: (image as ImageMetadata)?.height }] } + : {}), + }, + }, + { ...(post?.metadata ? { ...post.metadata, canonical: post.metadata?.canonical || url } : {}) } +) as MetaData; +--- + + + + {post.Content ? : } + + + + -- cgit v1.2.3